package com.luoxiang.socialandroid.adapter

import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CircleCrop
import com.bumptech.glide.request.RequestOptions
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.luoxiang.socialandroid.R
import com.luoxiang.socialandroid.bean.ListDetail
import com.luoxiang.socialandroid.common.Constants.MmkvConst.ACCID
import com.luoxiang.socialandroid.fragment.domain
import com.luoxiang.socialandroid.utils.MmkvUtil.decodeInt

/**
 * Author: fuxinbo

 * Date: 2023/2/9

 * Description: 魅力榜单适配器
 */
class CharmListDayAdapter : BaseQuickAdapter<ListDetail, BaseViewHolder>(R.layout.item_charm_list_day) {

    override fun convert(holder: BaseViewHolder, item: ListDetail) {
        holder.run {
            Glide.with(holder.itemView.context).load(domain + item.icon)
                .apply(RequestOptions.bitmapTransform(CircleCrop()))
                .into(holder.getView(R.id.imageUser))
            setText(R.id.textIndex, (holder.layoutPosition + 4).toString())
            setText(R.id.textName, item.name)
            setText(R.id.textReward, "距上名差：${item.distance}积分")
        }
        when (item.online) {
            0 -> {
                holder.getView<LinearLayout>(R.id.linearState)
                    .setBackgroundResource(R.drawable.bg_list_user_offline)
                holder.getView<View>(R.id.viewState)
                    .setBackgroundResource(R.drawable.bg_list_item_round_instructions_offline)
                holder.setText(R.id.textState, "离线")
            }
            1 -> {

            }
            2 -> {

            }
            3 -> {
                holder.getView<LinearLayout>(R.id.linearState)
                    .setBackgroundResource(R.drawable.bg_list_user_online)
                holder.getView<View>(R.id.viewState)
                    .setBackgroundResource(R.drawable.bg_list_item_round_instructions)
                holder.setText(R.id.textState, "在线")
            }
        }
    }

}